<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<tiles:insert page="/general/templateLoggedIn.jsp">
		<script type="text/javascript" src="http://www.google.com/jsapi"></script>
		
		<script type="text/javascript">
      		google.load('visualization', '1', {packages: ['corechart']});
    	</script>
    	
    	<script type="text/javascript">
      		function drawVisualization() {
        	// Create and populate the data table.
        	var data = new google.visualization.DataTable();
        	data.addColumn('string', 'Disciplines');
        	data.addColumn('number', 'Applicants');
        	data.addRows(${requestScope.visualizeDisciplines});
      
        	// Create and draw the visualization.
        	new google.visualization.PieChart(document.getElementById('visualization')).
	            draw(data, {title:"Disciplines of Applicants", backgroundColor:'transparent'});
      		}
      		google.setOnLoadCallback(drawVisualization);
    	</script>
	<tiles:put name="title" value="Discipline Analytics"/>
	<tiles:put name="nav"/>
	<tiles:put name="content" type="string">

		<h2>Discipline Analytics</h2>
		
		<div style="position: relative; float: left;">
			<table class="border">
				<tr>
					<th>
						Discipline
					</th>
					<th>
						Applications
					</th>
				</tr>
				<c:forEach var="discipline" items="${requestScope.disciplines}">
					<tr class="evenHover">
						<td>
							${discipline.discipline}
						</td>
						<td>
							<c:choose>
								<c:when test="${discipline.count == 0}">
									0
								</c:when>
								<c:otherwise>
									<html:link action="/showApplicants">
										<html:param name="type" value="disciplines"/>
										<html:param name="id" value="${discipline.id}"/>
										${discipline.count}
									</html:link>
								</c:otherwise>
							</c:choose>
						</td>
					</tr>
				</c:forEach>		
			</table>
		</div>
		<div id="visualization" style="width: 600px; height: 400px; margin-left: 400px;"></div>
		<div style="clear: left;"></div>

	</tiles:put>
</tiles:insert>	